$(document).ready(function() {

         var footerTotalName = "合计:";

         var _queryType = "1";

         var _maxConfirmDate = null;

         var purchaseTypeFullTreePath = BI.ajax.syncAjax("/innerApi/getPurchaseTypeFullTreePath.htm");

         var albumRoiOptions = {

                   title : '单剧ROI报表',

                   idField : 'acrId',

                   panelWidth : "100%",

                   height : $(document).height() - 16,

                   striped : true,

                   singleSelect : true,

                   showFooter : false,

                   pagination : true,

                   rownumbers : true,

                   pageSize : 50,

                   pageList : [20, 30, 50, 100],

                   toolbar : "#panel",

                   sortOrder : "desc",

                   sortName : "amtAmount",

                   showFooter : true,

                   loadMsg : '加载数据中，请稍后...',

                   url : '/finance/roiReportQuery.htm',

                   loader : function(param, success, error) {

                            var opts = $(this).datagrid("options");

                            if (!opts.url) {

                                     return false;

                            }

                            var me = this;

                            $.ajax({

                                                        type : opts.method,

                                                        url : opts.url,

                                                        data : param,

                                                        dataType : "json",

                                                        success : function(data) {

                                                                 // 处理footer

                                                                 var footer = data.footer;

                                                                 if (footer.length > 0) {

                                                                           footer[0]["purchaseBudgetTypeId"] = footerTotalName;

                                                                 } else {

                                                                           footer.push({

                                                                                                       "purchaseBudgetTypeId" : footerTotalName,

                                                                                                       "albumAmounts" : 0,

                                                                                                       "totalEpisodes" : 0,

                                                                                                       "amtAmount" : 0,

                                                                                                       "shareAmount" : 0,

                                                                                                       "disIncomeAmount" : 0,

                                                                                                       "vipIncomeAmount" : 0,

                                                                                                       "netCost" : 0,

                                                                                                       "vv" : 0,

                                                                                                       "ipmStorage" : 0,

                                                                                                       "ipm" : 0,

                                                                                                       "vvCostPerThousand" : 0,

                                                                                                       "ipmStorageCost" : 0,

                                                                                                       "ipmCost" : 0

                                                                                             });

                                                                 }

                                                                 console.log("loader::", data);

                                                                 success(data);

                                                        },

                                                        error : function(arguments) {

                                                                 error.apply(this, arguments);

                                                        }

                                               });

                   },

                   onLoadSuccess : function(data) {

                            var $obj = $('#datalist').datagrid("getPanel").find("div.datagrid-view2 div.datagrid-header div.datagrid-cell");

                            if (!$obj.hasClass("datagrid-sort-asc") && !$obj.hasClass("datagrid-sort-desc")) {

                                     $('#datalist').datagrid("getPanel").find("div.datagrid-view2 div.datagrid-header td[field='amtAmount'] div.datagrid-cell")

                                                        .addClass("datagrid-sort-desc");

                            }

                            BI.Widget.bindResize({

                                                        "resizeId" : "datalist"

                                               });

                   },

                   frozenColumns : [[{

                                               width : BI.Widget.fixWidth(0.1),

                                               title : "片名",

                                               field : "albumName",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return "<div title='{0}'>{0}</div>".format(value);

                                               }

                                     }, {

                                               width : BI.Widget.fixWidth(0.1),

                                               title : "授权时间",

                                               field : "authBeginTime",

                                               align : "center",

                                               formatter : function(value, row, index) {

                                                        if (BI.isEmpty(value) || BI.isEmpty(row.authEndTime)) {

                                                                 return "";

                                                        }

                                                        var str = [BI.parseDate(value), BI.parseDate(row.authEndTime)].join("至");

                                                        return '<div title="{0}">{0}</div>'.format(str);

                                               }

                                     }, {

                                               title : "摊销日期",

                                               field : "amtBeginTime",

                                               resizable : true,

                                               align : "center",

                                               width : BI.Widget.fixWidth(0.1),

                                               formatter : function(value, row, index) {

                                                        if (BI.isEmpty(value) || BI.isEmpty(row.amtEndTime)) {

                                                                 if (row.cashDate) {

                                                                           return '<div title="摊销确认日期：{0}"></div>'.format(BI.parseDate(row.cashDate));

                                                                 } else {

                                                                           return "";

                                                                 }

                                                        } else {

                                                                 var str = [BI.parseDate(value), BI.parseDate(row.amtEndTime)].join("至");

                                                                 return '<div title="摊销日期：{0}&#13;摊销确认日期：{1}">{0}</div>'.format(str, BI.parseDate(row.cashDate));

                                                        }

                                              }

                                     }, {

                                               title : "上线时间",

                                               field : "issueTime",

                                               resizable : true,

                                               align : "center",

                                               width : BI.Widget.fixWidth(0.07),

                                               formatter : function(value, row, index) {

                                                        return BI.parseDate(value);

                                               }

                                     }, {

                                               title : "合同编号",

                                               field : "contractNumber",

                                               resizable : true,

                                               width : BI.Widget.fixWidth(0.07),

                                               formatter : function(value, row, index) {

                                                        return '<div title="{0}">{0}</div>'.format(value);

                                               }

                                     }, {

                                               title : "版权方",

                                               field : "ownerName",

                                               resizable : true,

                                               width : BI.Widget.fixWidth(0.1),

                                               formatter : function(value, row, index) {

                                                        return '<div title="{0}">{0}</div>'.format(value);

                                               }

                                     }, {

                                               title : "科目",

                                               field : "purchaseBudgetTypeId",

                                               resizable : true,

                                               width : BI.Widget.fixWidth(0.1),

                                               formatter : function(value, row, index) {

                                                        if (value == footerTotalName) {

                                                                 return "<div class='tr'>{0}</div>".format(value);

                                                        }

                                                        return "<div title='{0}'>{0}</div>".format(purchaseTypeFullTreePath[value]);

                                               }

                                     }]],

                   columns : [[{

                                               title : "<a href='javascript:void(0);'>上线部数</a>",

                                               field : "albumAmounts",

                                               resizable : true,

                                               align : "right",

                                               width : BI.Widget.fixWidth(0.04),

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        if (row.purchaseBudgetTypeId != footerTotalName) {

                                                                 value = 1;

                                                        }

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>集数</a>",

                                               field : "totalEpisodes",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>摊销成本</a>",

                                               field : "amtAmount",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>分成成本</a>",

                                               field : "shareAmount",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>分销收入</a>",

                                               field : "disIncomeAmount",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>付费收入</a>",

                                               field : "vipIncomeAmount",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>净成本</a>",

                                               field : "netCost",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                              order : "desc",

                                               formatter : function(value, row, index) {

                                                        var data = $("#datalist").datagrid("getData");

                                                        var albumRelation = data["albumRelation"];

                                                        if (albumRelation && albumRelation[row.albumId] && albumRelation[row.albumId].type == 2) {// 副剧

                                                                 var refList = albumRelation[row.albumId].refList;

                                                                 var albumName = refList.length > 0 ? refList[0].albumName : "";

                                                                 return '<div title="{0}">{0}</div>'.format("同主剧《" + albumName + "》");

                                                        } else {

                                                                 return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                                        }

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>VV</a>",

                                               field : "vv",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>库存IPM</a>",

                                               field : "ipmStorage",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>实投IPM</a>",

                                               field : "ipm",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>千次vv成本</a>",

                                               field : "vvCostPerThousand",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                              }

                                     }, {

                                               title : "<a href='javascript:void(0);'>库存IPM成本</a>",

                                               field : "ipmStorageCost",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>实投IPM成本</a>",

                                               field : "ipmCost",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }]]

         };

         var treeOptons = {

                   title : '单剧ROI报表',

                   idField : 'id',

                   treeField : "text",

                   height : $(document).height() - 16,

                   rownumbers : true,

                   showFooter : true,

                   url : "/finance/roiReportPurchaseTree.htm",

                   toolbar : "#panel",

                   onLoadSuccess : function(data) {

                            BI.Widget.bindResize({

                                                        "resizeId" : "treegrid",

                                                        "resize" : function(resizeId) {

                                                                 $('#' + resizeId).treegrid('resize', {

                                                                                             width : BI.Widget.getClientWidth() - 16,

                                                                                             height : BI.Widget.getClientHeight() - 16

                                                                                    });

                                                        }

                                               });

                   },

                   columns : [[{

                                               width : BI.Widget.fixWidth(0.2),

                                               title : "采购类型",

                                               field : "text",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return "<div title='{0}'>{0}</div>".format(value);

                                               }

                                     }, {

                                               title : "上线部数",

                                               field : "albumCount",

                                               resizable : true,

                                               align : "center",

                                               width : BI.Widget.fixWidth(0.04),

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "集数",

                                               field : "episodeCount",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "摊销成本",

                                               field : "amtAmount",

                                               width : BI.Widget.fixWidth(0.07),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "分成成本",

                                               field : "shareAmount",

                                               width : BI.Widget.fixWidth(0.07),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "分销成本",

                                               field : "disIncomeAmount",

                                               width : BI.Widget.fixWidth(0.07),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "付费收入",

                                               field : "vipIncomeAmount",

                                               width : BI.Widget.fixWidth(0.07),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "净成本",

                                               field : "netCost",

                                               width : BI.Widget.fixWidth(0.07),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "VV",

                                               field : "vv",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "库存IPM",

                                               field : "ipmStorage",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "实投IPM",

                                               field : "ipm",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "千次vv成本",

                                               field : "vvCostPerThousand",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "库存IPM成本",

                                               field : "ipmStorageCost",

                                               width : BI.Widget.fixWidth(0.05),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "实投IPM成本",

                                               field : "ipmCost",

                                               width : BI.Widget.fixWidth(0.06),

                                               align : "right",

                                               resizable : true,

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }]]

         };

         // 版权方查询option start

         var copyrightRoiOptions = {

                   title : '单剧ROI报表',

                   idField : 'cpyId',

                   panelWidth : "100%",

                   height : $(document).height() - 16,

                   striped : true,

                   singleSelect : true,

                   showFooter : false,

                   fitColumns : true,

                   pagination : true,

                   rownumbers : true,

                   pageSize : 50,

                   pageList : [20, 30, 50, 100],

                   toolbar : "#panel",

                   sortOrder : "desc",

                   sortName : "amtAmount",

                   showFooter : true,

                   loadMsg : '加载数据中，请稍后...',

                   url : '/finance/albumRoiQueryByCpr.htm',

                   loader : function(param, success, error) {

                            var opts = $(this).datagrid("options");

                            if (!opts.url) {

                                     return false;

                            }

                            $.ajax({

                                                        type : opts.method,

                                                        url : opts.url,

                                                        data : param,

                                                        dataType : "json",

                                                        success : function(data) {

                                                                 // 处理footer

                                                                 var footer = data.footer;

                                                                 if (footer.length > 0) {

                                                                           footer[0]["ownerName"] = "合计";

                                                                 } else {

                                                                           footer.push({

                                                                                                       "ownerName" : "合计",

                                                                                                       "albumCountByCpr" : 0,

                                                                                                       "totalEpisodes" : 0,

                                                                                                       "amtAmount" : 0,

                                                                                                       "shareAmount" : 0,

                                                                                                       "disIncomeAmount" : 0,

                                                                                                       "vipIncomeAmount" : 0

                                                                                             });

                                                                 }

                                                                 console.log("loader::", data);

                                                                 success(data);

                                                        },

                                                        error : function(arguments) {

                                                                 error.apply(this, arguments);

                                                        }

                                               });

                   },

                   onLoadSuccess : function(data) {

                            var $obj = $('#datalist').datagrid("getPanel").find("div.datagrid-view2 div.datagrid-header div.datagrid-cell");

                            if (!$obj.hasClass("datagrid-sort-asc") && !$obj.hasClass("datagrid-sort-desc")) {

                                     $('#datalist').datagrid("getPanel").find("div.datagrid-view2 div.datagrid-header td[field='amtAmount'] div.datagrid-cell")

                                                        .addClass("datagrid-sort-desc");

                            }

                            BI.Widget.bindResize({

                                                        "resizeId" : "datalist"

                                               });

                   },

                   columns : [[{

                                               title : "版权方",

                                               field : "ownerName",

                                               resizable : true,

                                               width : BI.Widget.fixWidth(0.10),

                                               formatter : function(value, row, index) {

                                                        return '<span title="{0}">{0}</span>'.format(value);

                                               }

                                     }, {

                                               title : "上线部数",

                                               field : "albumCountByCpr",

                                               resizable : true,

                                              align : "center",

                                               width : BI.Widget.fixWidth(0.04),

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>集数</a>",

                                               field : "totalEpisodes",

                                               width : BI.Widget.fixWidth(0.04),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>摊销成本</a>",

                                               field : "amtAmount",

                                               width : BI.Widget.fixWidth(0.04),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>分成成本</a>",

                                               field : "shareAmount",

                                               width : BI.Widget.fixWidth(0.04),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>分销收入</a>",

                                               field : "disIncomeAmount",

                                               width : BI.Widget.fixWidth(0.04),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }, {

                                               title : "<a href='javascript:void(0);'>付费收入</a>",

                                               field : "vipIncomeAmount",

                                               width : BI.Widget.fixWidth(0.04),

                                               align : "right",

                                               resizable : true,

                                               sortable : true,

                                               order : "desc",

                                               formatter : function(value, row, index) {

                                                        return BI.isEmpty(value) ? "" : FormatUtil.patternNum(value, "###,###,###,##0.00");

                                               }

                                     }]]

         };

         $("input[name=dataType]").bind("click", function() {

                                     var value = $(this).val();

                                     if (value == "1") {

                                               _queryType = "1";

                                               $("#treeGridDiv").hide();

                                               $("#dataListDiv").show();

                                     } else if (value == "2") {

                                               _queryType = "2";

                                               $("#dataListDiv").hide();

                                               $("#treeGridDiv").show();

                                     } else if (value == "3") { //按版权方查询wanglei

                                               _queryType = "3";

                                               $("#searchCondition").show();

                                               $("#dataListDiv").show();

                                               $("#atSearch").hide();

                                               $("#treeGridDiv").hide();

                                     }

                                     $('#queryTypeId').comboquery("doSearch");

                            });

         $('#queryTypeId').comboquery({

                                     width : 200,

                                     panelHeight : 'auto',

                                     valueField : 'id',

                                     textField : 'text',

                                     includes : ["albumName", "issueTime", "contractNumber", "ownerName", "purchaseBudgetTypeIds"],

                                     onReset : function() {

                                               $("#cashDateStart").val("");

                                               $("#cashDateEnd").val("");

                                     },

                                     onBeforeSubmit : function(params) {

                                               var cashDateEnd = $("#cashDateEnd").val();

                                               if (BI.isEmpty(cashDateEnd)) {

                                                        cashDateEnd = _maxConfirmDate;

                                                        $("#cashDateEnd").val(_maxConfirmDate);

                                               }

                                               $.extend(params, {

                                                                           "cashDateStart" : $("#cashDateStart").val(),

                                                                           "cashDateEnd" : cashDateEnd

                                                                 });

                                               return true;

                                     },

                                     onSubmit : function(params, options) {

                                               if (_queryType == "1") {

                                                        albumRoiOptions.queryParams = params;

                                                        $('#datalist').datagrid(albumRoiOptions).datagrid("getPager").pagination("select", 1);

                                               } else if (_queryType == "2") {

                                                        treeOptons.queryParams = params;

                                                        $('#treegrid').treegrid(treeOptons);

                                               }

                                     }

                            });

         $.getJSON($("#apiGetMaxConfirmDate").val(), function(data) {

                                     if (!BI.isEmpty(data.maxConfirmDate)) {

                                               _maxConfirmDate = data.maxConfirmDate;

                                               $("#cashDateStart").val(data.maxConfirmDate);

                                               $("#cashDateEnd").val(data.maxConfirmDate);

                                               albumRoiOptions.queryParams = {

                                                        "cashDateStart" : data.maxConfirmDate,

                                                        "cashDateEnd" : data.maxConfirmDate

                                               };

                                               $("#cashDateStart").mydatepicker({

                                                                           dateFmt : "yyyy-MM",

                                                                           onBeforeClick : function(opts) {

                                                                                    opts.maxDate = $('#cashDateEnd').val() ? '#F{$dp.$D(\'cashDateEnd\')}' : data.maxConfirmDate;

                                                                           }

                                                                 });

                                               $("#cashDateEnd").mydatepicker({

                                                                           dateFmt : "yyyy-MM",

                                                                           maxDate : data.maxConfirmDate,

                                                                           minDate : '#F{$dp.$D(\'cashDateStart\')}'

                                                                 });

                                     } else {

                                               $("#cashDateStart").mydatepicker({

                                                                           dateFmt : "yyyy-MM",

                                                                           onBeforeClick : function(opts) {

                                                                                    opts.maxDate = $('#cashDateEnd').val() ? '#F{$dp.$D(\'cashDateEnd\')}' : null;

                                                                           }

                                                                 });

                                               $("#cashDateEnd").mydatepicker({

                                                                           dateFmt : "yyyy-MM",

                                                                           minDate : '#F{$dp.$D(\'cashDateStart\')}'

                                                                 });

                                     }

                                     $('#datalist').datagrid(albumRoiOptions);

                            });

});
 
